package mo.leetcode_top;

public class L204 {

    public int countPrimes(int n) {
        int res = 0;
        boolean[] prime = new boolean[n];
        for (int i = 0; i < n; i++) {
            prime[i] = true;
        }
        for (int i = 2; i < n; i++) {
            if (!prime[i]) {
                continue;
            }
            res++;
            for (int j = 2; j * i < n; j++) {
                prime[i*j] = false;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        L204 test = new L204();
        System.out.println(test.countPrimes(10));
    }
}
